package com.xinqi.modules.exam.paper.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xinqi.common.mybatis.data.repo.SuperMapper;
import com.xinqi.modules.exam.paper.domain.CourseExamPaperStatsEntity;
import com.xinqi.modules.exam.paper.dto.req.CourseExamPaperStatsQueryDTO;
import com.xinqi.modules.exam.paper.dto.rsp.CourseExamPaperStatsResultDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 课程测评统计数据层
 *
 * @author: linkai
 * @date: 2023/07/02
 */
@Mapper
public interface CourseExamPaperStatsMapper extends SuperMapper<CourseExamPaperStatsEntity> {
    Page<CourseExamPaperStatsResultDTO> findPage(Page<Object> page, @Param("dto") CourseExamPaperStatsQueryDTO query);

    List<CourseExamPaperStatsResultDTO> findList(@Param("dto") CourseExamPaperStatsQueryDTO query);

    @Update("update co_course_exam_paper_stats set total_num = #{totalNum} where exam_paper_id = #{examId}")
    int updateTotalNumById(@Param("examId") Long examId, @Param("totalNum") Integer totalNum);

    @Update("update co_course_exam_paper_stats set submitted_num = submitted_num + #{num} where exam_paper_id = #{examId}")
    int updateAddSubmittedNumById(@Param("examId") Long examId, @Param("num") Integer num);

    @Update("update co_course_exam_paper_stats set approved_num = approved_num + #{num} where exam_paper_id = #{examId}")
    int updateAddApprovedNumById(@Param("examId") Long examId, @Param("num") Integer num);

    int updateRejectPaperById(@Param("examId") Long examId, @Param("examId") List<Long> rejectStudentIdList);
}
